﻿USE [VideoServices]
GO
/****** Object:  ForeignKey [FK_Deliveries_Orders]    Script Date: 05/02/2010 11:34:42 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Deliveries_Orders]') AND parent_object_id = OBJECT_ID(N'[dbo].[Deliveries]'))
ALTER TABLE [dbo].[Deliveries] DROP CONSTRAINT [FK_Deliveries_Orders]
GO
/****** Object:  ForeignKey [FK_Deliveries_Warehouse]    Script Date: 05/02/2010 11:34:42 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Deliveries_Warehouse]') AND parent_object_id = OBJECT_ID(N'[dbo].[Deliveries]'))
ALTER TABLE [dbo].[Deliveries] DROP CONSTRAINT [FK_Deliveries_Warehouse]
GO
/****** Object:  ForeignKey [FK_Orderline_Catalogue]    Script Date: 05/02/2010 11:34:43 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Orderline_Catalogue]') AND parent_object_id = OBJECT_ID(N'[dbo].[Orderline]'))
ALTER TABLE [dbo].[Orderline] DROP CONSTRAINT [FK_Orderline_Catalogue]
GO
/****** Object:  ForeignKey [FK_Orderline_Orders]    Script Date: 05/02/2010 11:34:43 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Orderline_Orders]') AND parent_object_id = OBJECT_ID(N'[dbo].[Orderline]'))
ALTER TABLE [dbo].[Orderline] DROP CONSTRAINT [FK_Orderline_Orders]
GO
/****** Object:  ForeignKey [FK_Orders_Customers]    Script Date: 05/02/2010 11:34:45 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Orders_Customers]') AND parent_object_id = OBJECT_ID(N'[dbo].[Orders]'))
ALTER TABLE [dbo].[Orders] DROP CONSTRAINT [FK_Orders_Customers]
GO
/****** Object:  ForeignKey [FK_Orders_Store]    Script Date: 05/02/2010 11:34:46 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Orders_Store]') AND parent_object_id = OBJECT_ID(N'[dbo].[Orders]'))
ALTER TABLE [dbo].[Orders] DROP CONSTRAINT [FK_Orders_Store]
GO
/****** Object:  ForeignKey [FK_Orders_Warehouse]    Script Date: 05/02/2010 11:34:46 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Orders_Warehouse]') AND parent_object_id = OBJECT_ID(N'[dbo].[Orders]'))
ALTER TABLE [dbo].[Orders] DROP CONSTRAINT [FK_Orders_Warehouse]
GO
/****** Object:  ForeignKey [FK_Stock_Catalogue]    Script Date: 05/02/2010 11:34:47 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Stock_Catalogue]') AND parent_object_id = OBJECT_ID(N'[dbo].[Stock]'))
ALTER TABLE [dbo].[Stock] DROP CONSTRAINT [FK_Stock_Catalogue]
GO
/****** Object:  ForeignKey [FK_Stock_Warehouse]    Script Date: 05/02/2010 11:34:47 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Stock_Warehouse]') AND parent_object_id = OBJECT_ID(N'[dbo].[Stock]'))
ALTER TABLE [dbo].[Stock] DROP CONSTRAINT [FK_Stock_Warehouse]
GO
/****** Object:  Table [dbo].[Orderline]    Script Date: 05/02/2010 11:34:43 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Orderline]') AND type in (N'U'))
DROP TABLE [dbo].[Orderline]
GO
/****** Object:  Table [dbo].[Stock]    Script Date: 05/02/2010 11:34:47 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Stock]') AND type in (N'U'))
DROP TABLE [dbo].[Stock]
GO
/****** Object:  Table [dbo].[Deliveries]    Script Date: 05/02/2010 11:34:42 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Deliveries]') AND type in (N'U'))
DROP TABLE [dbo].[Deliveries]
GO
/****** Object:  Table [dbo].[Catalogue]    Script Date: 05/02/2010 11:34:40 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Catalogue]') AND type in (N'U'))
DROP TABLE [dbo].[Catalogue]
GO
/****** Object:  Table [dbo].[Orders]    Script Date: 05/02/2010 11:34:45 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Orders]') AND type in (N'U'))
DROP TABLE [dbo].[Orders]
GO
/****** Object:  Table [dbo].[Warehouse]    Script Date: 05/02/2010 11:34:49 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Warehouse]') AND type in (N'U'))
DROP TABLE [dbo].[Warehouse]
GO
/****** Object:  Table [dbo].[Customers]    Script Date: 05/02/2010 11:34:41 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Customers]') AND type in (N'U'))
DROP TABLE [dbo].[Customers]
GO
/****** Object:  Table [dbo].[Store]    Script Date: 05/02/2010 11:34:48 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Store]') AND type in (N'U'))
DROP TABLE [dbo].[Store]
GO
/****** Object:  Table [dbo].[Customers]    Script Date: 05/02/2010 11:34:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Customers]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Customers](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[name] [nvarchar](80) NULL,
	[address] [nvarchar](150) NULL,
 CONSTRAINT [PK_Customers] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Customers]') AND name = N'name_UI')
CREATE UNIQUE NONCLUSTERED INDEX [name_UI] ON [dbo].[Customers] 
(
	[name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Catalogue]    Script Date: 05/02/2010 11:34:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Catalogue]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Catalogue](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[catalogue_no] [nvarchar](50) NOT NULL,
	[title] [nvarchar](150) NOT NULL,
	[director] [nvarchar](80) NOT NULL,
	[genre] [nvarchar](20) NOT NULL,
	[price] [float] NOT NULL,
 CONSTRAINT [PK_Videos_1] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Catalogue]') AND name = N'catalogue_no_UI')
CREATE UNIQUE NONCLUSTERED INDEX [catalogue_no_UI] ON [dbo].[Catalogue] 
(
	[catalogue_no] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Warehouse]    Script Date: 05/02/2010 11:34:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Warehouse]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Warehouse](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[name] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_Warehouse] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Warehouse]') AND name = N'name_UI')
CREATE UNIQUE NONCLUSTERED INDEX [name_UI] ON [dbo].[Warehouse] 
(
	[name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Store]    Script Date: 05/02/2010 11:34:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Store]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Store](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[name] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_Store] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Store]') AND name = N'name_UI')
CREATE UNIQUE NONCLUSTERED INDEX [name_UI] ON [dbo].[Store] 
(
	[name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Orders]    Script Date: 05/02/2010 11:34:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Orders]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Orders](
	[id] [uniqueidentifier] NOT NULL,
	[customer_id] [int] NOT NULL,
	[total] [float] NOT NULL,
	[order_date] [datetime] NOT NULL,
	[warehouse_id] [int] NOT NULL,
	[store_id] [int] NOT NULL,
	[status] [int] NOT NULL,
 CONSTRAINT [PK_Orders] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Orderline]    Script Date: 05/02/2010 11:34:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Orderline]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Orderline](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[order_id] [uniqueidentifier] NOT NULL,
	[catalogue_id] [int] NOT NULL,
	[quantity] [int] NOT NULL,
 CONSTRAINT [PK_Orderline] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Stock]    Script Date: 05/02/2010 11:34:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Stock]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Stock](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[catalogue_id] [int] NOT NULL,
	[warehouse_id] [int] NOT NULL,
	[holding] [int] NOT NULL,
 CONSTRAINT [PK_Stock] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Stock]') AND name = N'Catalogue_Warehouse_UI')
CREATE UNIQUE NONCLUSTERED INDEX [Catalogue_Warehouse_UI] ON [dbo].[Stock] 
(
	[catalogue_id] ASC,
	[warehouse_id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Deliveries]    Script Date: 05/02/2010 11:34:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Deliveries]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Deliveries](
	[id] [uniqueidentifier] NOT NULL,
	[order_id] [uniqueidentifier] NOT NULL,
	[warehouse_id] [int] NOT NULL,
	[delivery_date] [datetime] NOT NULL,
	[status] [int] NOT NULL,
 CONSTRAINT [PK_Delivery] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Deliveries]') AND name = N'delivery_date_status_UI')
CREATE UNIQUE NONCLUSTERED INDEX [delivery_date_status_UI] ON [dbo].[Deliveries] 
(
	[delivery_date] ASC,
	[status] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  ForeignKey [FK_Deliveries_Orders]    Script Date: 05/02/2010 11:34:42 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Deliveries_Orders]') AND parent_object_id = OBJECT_ID(N'[dbo].[Deliveries]'))
ALTER TABLE [dbo].[Deliveries]  WITH CHECK ADD  CONSTRAINT [FK_Deliveries_Orders] FOREIGN KEY([order_id])
REFERENCES [dbo].[Orders] ([id])
GO
ALTER TABLE [dbo].[Deliveries] CHECK CONSTRAINT [FK_Deliveries_Orders]
GO
/****** Object:  ForeignKey [FK_Deliveries_Warehouse]    Script Date: 05/02/2010 11:34:42 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Deliveries_Warehouse]') AND parent_object_id = OBJECT_ID(N'[dbo].[Deliveries]'))
ALTER TABLE [dbo].[Deliveries]  WITH CHECK ADD  CONSTRAINT [FK_Deliveries_Warehouse] FOREIGN KEY([warehouse_id])
REFERENCES [dbo].[Warehouse] ([id])
GO
ALTER TABLE [dbo].[Deliveries] CHECK CONSTRAINT [FK_Deliveries_Warehouse]
GO
/****** Object:  ForeignKey [FK_Orderline_Catalogue]    Script Date: 05/02/2010 11:34:43 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Orderline_Catalogue]') AND parent_object_id = OBJECT_ID(N'[dbo].[Orderline]'))
ALTER TABLE [dbo].[Orderline]  WITH CHECK ADD  CONSTRAINT [FK_Orderline_Catalogue] FOREIGN KEY([catalogue_id])
REFERENCES [dbo].[Catalogue] ([id])
GO
ALTER TABLE [dbo].[Orderline] CHECK CONSTRAINT [FK_Orderline_Catalogue]
GO
/****** Object:  ForeignKey [FK_Orderline_Orders]    Script Date: 05/02/2010 11:34:43 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Orderline_Orders]') AND parent_object_id = OBJECT_ID(N'[dbo].[Orderline]'))
ALTER TABLE [dbo].[Orderline]  WITH CHECK ADD  CONSTRAINT [FK_Orderline_Orders] FOREIGN KEY([order_id])
REFERENCES [dbo].[Orders] ([id])
GO
ALTER TABLE [dbo].[Orderline] CHECK CONSTRAINT [FK_Orderline_Orders]
GO
/****** Object:  ForeignKey [FK_Orders_Customers]    Script Date: 05/02/2010 11:34:45 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Orders_Customers]') AND parent_object_id = OBJECT_ID(N'[dbo].[Orders]'))
ALTER TABLE [dbo].[Orders]  WITH CHECK ADD  CONSTRAINT [FK_Orders_Customers] FOREIGN KEY([customer_id])
REFERENCES [dbo].[Customers] ([id])
GO
ALTER TABLE [dbo].[Orders] CHECK CONSTRAINT [FK_Orders_Customers]
GO
/****** Object:  ForeignKey [FK_Orders_Store]    Script Date: 05/02/2010 11:34:46 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Orders_Store]') AND parent_object_id = OBJECT_ID(N'[dbo].[Orders]'))
ALTER TABLE [dbo].[Orders]  WITH CHECK ADD  CONSTRAINT [FK_Orders_Store] FOREIGN KEY([store_id])
REFERENCES [dbo].[Store] ([id])
GO
ALTER TABLE [dbo].[Orders] CHECK CONSTRAINT [FK_Orders_Store]
GO
/****** Object:  ForeignKey [FK_Orders_Warehouse]    Script Date: 05/02/2010 11:34:46 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Orders_Warehouse]') AND parent_object_id = OBJECT_ID(N'[dbo].[Orders]'))
ALTER TABLE [dbo].[Orders]  WITH CHECK ADD  CONSTRAINT [FK_Orders_Warehouse] FOREIGN KEY([warehouse_id])
REFERENCES [dbo].[Warehouse] ([id])
GO
ALTER TABLE [dbo].[Orders] CHECK CONSTRAINT [FK_Orders_Warehouse]
GO
/****** Object:  ForeignKey [FK_Stock_Catalogue]    Script Date: 05/02/2010 11:34:47 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Stock_Catalogue]') AND parent_object_id = OBJECT_ID(N'[dbo].[Stock]'))
ALTER TABLE [dbo].[Stock]  WITH CHECK ADD  CONSTRAINT [FK_Stock_Catalogue] FOREIGN KEY([catalogue_id])
REFERENCES [dbo].[Catalogue] ([id])
GO
ALTER TABLE [dbo].[Stock] CHECK CONSTRAINT [FK_Stock_Catalogue]
GO
/****** Object:  ForeignKey [FK_Stock_Warehouse]    Script Date: 05/02/2010 11:34:47 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Stock_Warehouse]') AND parent_object_id = OBJECT_ID(N'[dbo].[Stock]'))
ALTER TABLE [dbo].[Stock]  WITH CHECK ADD  CONSTRAINT [FK_Stock_Warehouse] FOREIGN KEY([warehouse_id])
REFERENCES [dbo].[Warehouse] ([id])
GO
ALTER TABLE [dbo].[Stock] CHECK CONSTRAINT [FK_Stock_Warehouse]
GO
